<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('school/index')}">所有学校</a></li>
        <li class="active"><a href="{:url('school/add')}">添加学校</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form margin-top-20" action="{:url('school/addPost')}" method="post">
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">所属省份:</label>
            <div class="col-md-6 col-sm-10">
                <select name="province" id="province" lay-filter="selectSchool" style="width:100%">
                    <option value="">--请选择省份--</option>
                    <foreach name="province" item="vo">
                        <option value="{$vo.areaId}">{$vo.areaName}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">所属城市:</label>
            <div class="col-md-6 col-sm-10">
                <select name="city" id="city" lay-filter="selectSchool" style="width:100%">
                    <option value="">--请选择城市--</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">所属县区:</label>
            <div class="col-md-6 col-sm-10">
                <select name="area" id="area" lay-filter="selectSchool" style="width:100%">
                    <option value="">--请选择县区--</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">详细住址:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-name" name="address">
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">学校名称:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-name" name="name">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
                <a class="btn btn-default" href="{:url('admin/school/index')}">{:lang('BACK')}</a>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    $(function(){
        $('#province').on('change',function(){
          var  areaId = $(this).val();
          $.ajax({
              url:"{:url('school/getCity')}",
              type:"POST",
              data:{areaId:areaId},
              success:function(res) {
                  $('#city').html(res);
                  console.log(res);
              }
          })
        })
    })
</script>
<script>
    $(function(){
        $('#city').on('change',function(){
            var cityId=$(this).val();
            $.ajax({
                url:"{:url('school/getArea')}",
                type:"POST",
                data:{cityId:cityId},
                success:function (res) {
                    $('#area').html(res);
                    console.log(res);
                }
            })
        })
    })
</script>
</body>
</html>